<template>
  <div>
    <el-table :data="pageInfo" style="width: 100%">
      <el-table-column prop="key" label="流程定义key"/>
      <el-table-column prop="name" label="流程名称"/>
      <el-table-column label="操作" width="300">
        <template #default="scope" >
          <el-button size="small" type="success" @click="lookmange(scope.row)">发起</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div style="float: right;padding-top: 1%">
      <el-pagination v-model:current-page="pageNum" v-model:page-size="pageSize" background layout="prev, pager, next" :total="total" @current-change="handleCurrentChange"/>
    </div>
  </div>
  <div id="froms">
    <div id="addOutSideDialog">
      <el-dialog v-model="addoutSide" fullscreen>
        <el-form :model="addobject" label-width="120px">
          <el-form-item label="姓名">
            <el-input v-model="addobject.sysUserName" readonly />
          </el-form-item>
          <el-form-item label="部门">
            <el-input v-model="addobject.sysDeptName" readonly />
          </el-form-item>
          <el-form-item label="岗位">
            <el-input v-model="addobject.job" />
          </el-form-item>
          <el-form-item label="是否有工作计划：" label-width="150">
            <el-radio-group v-model="addobject.planeFlag" class="ml-4">
              <el-radio label="0" size="large">否</el-radio>
              <el-radio label="1" size="large">是</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="是否通过审批：" label-width="150">
            <el-radio-group v-model="addobject.agreeFlag" class="ml-4">
              <el-radio label="0" size="large">否</el-radio>
              <el-radio label="1" size="large">是</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="出发和返回时间：" label-width="150">
            <div class="block">
              <el-date-picker
                  v-model="exporttimes"
                  type="datetimerange"
                  range-separator="至"
                  start-placeholder="预计出发时间"
                  end-placeholder="预计返回时间"
              />
            </div>
          </el-form-item>
          <el-form-item label="出差性质">
            <el-select v-model="addobject.evectionType" placeholder="请选择出差性质">
              <el-option label="陌拜" value="陌拜" />
              <el-option label="回访" value="回访" />
              <el-option label="立项" value="立项" />
              <el-option label="签单" value="签单" />
              <el-option label="其他" value="其他" />
            </el-select>
          </el-form-item>
          <el-form-item label="出发地">
            <el-input v-model="addobject.departurePlace"  />
          </el-form-item>
          <el-form-item label="目的地">
            <el-input v-model="addobject.destinationPlace"  />
          </el-form-item>
          <el-form-item label="出差计划">
            <el-input type="textarea" v-model="addobject.evectionProject"></el-input>
          </el-form-item>
          <el-form-item label="出差目的">
            <el-input type="textarea" v-model="addobject.evectionTarget"></el-input>
          </el-form-item>
          <el-form-item label="交通工具">
            <el-select v-model="addobject.transportation" placeholder="请选择交通工具">
              <el-option label="飞机" value="飞机" />
              <el-option label="高铁" value="高铁" />
              <el-option label="火车" value="火车" />
              <el-option label="客车" value="客车" />
              <el-option label="自驾" value="自驾" />
              <el-option label="其他" value="其他" />
            </el-select>
          </el-form-item>
          <el-form-item label="申请人">
            <el-input v-model="addobject.sysUserName" readonly />
          </el-form-item>
<!--          <el-form-item label="审批主管">-->
<!--            <el-select v-model="addobject.deptLeader" placeholder="请选择审批主管">-->
<!--              <el-option v-for="item in checkUserList" :label="item.userName" :value="item.loginName" />-->
<!--            </el-select>-->
<!--          </el-form-item>-->
        </el-form>
        <div style="padding: 1rem">
          <el-button @click="addoutSide=false">取消</el-button>
          <el-button type="primary" @click="conAddoutSide()">确认</el-button>
        </div>
      </el-dialog>
    </div>
    <div id="addHospitalInfoDialog">
      <el-dialog v-model="addHospital" fullscreen>
          <el-form :model="addHospatilObject"   >
            <el-row>
              <el-col :span="6">
                <el-form-item    label="医院名称">
                <el-input v-model="addHospatilObject.hospitalName"></el-input>
              </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item   label="医院地址">
                  <el-input v-model="addHospatilObject.hospitalAddress"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item  label="医院等级">
                  <el-select v-model="addHospatilObject.hospitalLv" placeholder="请选择等级">
                    <el-option label="三级特等" value="三级特等"></el-option>
                    <el-option label="三级甲等" value="三级甲等"></el-option>
                    <el-option label="三级乙等" value="三级乙等"></el-option>
                    <el-option label="三级丙等" value="三级丙等"></el-option>
                    <el-option label="二级甲等" value="二级甲等"></el-option>
                    <el-option label="二级乙等" value="二级乙等"></el-option>
                    <el-option label="二级丙等" value="二级丙等"></el-option>
                    <el-option label="一级甲等" value="一级甲等"></el-option>
                    <el-option label="一级乙等" value="一级乙等"></el-option>
                    <el-option label="一级丙等" value="一级丙等"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item   label="医联体" >
                  <el-input v-model="addHospatilObject.hospitalConsortium"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="6">
                <el-form-item    label="互联网医院">
                  <el-switch
                      v-model="addHospatilObject.hospitalInternet"
                      active-color="#13ce66"
                      active-value="1"
                      inactive-value="0"
                      inactive-text="否"
                      active-text="是"
                      inactive-color="#ff4949">
                  </el-switch>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item    label="重点科室">
                  <el-input v-model="addHospatilObject.keyDepartment"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item   label="医院床位" >
                  <el-input type="number" v-model="addHospatilObject.hospitalBad"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item   label="医院门诊量"  >
                  <el-input type="number" v-model="addHospatilObject.hospitalService"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="6">
                <el-form-item    label="目标科室" prop="name">
                  <el-input v-model="addHospatilObject.targetDepartment"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item   label="医生数" prop="number" >
                  <el-input type="number" v-model="addHospatilObject.doctorNumber"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">

                <el-form-item    label="高级职称数" prop="number" >
                  <el-input type="number" v-model="addHospatilObject.highNumber"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item  label="心理医生资质数" prop="number" >
                  <el-input type="number" v-model="addHospatilObject.psychologistNumber"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
            <el-col :span="6">
              <el-form-item    label="主要患者类型" prop="name">
                <el-input v-model="addHospatilObject.mainPatientTypes"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item    label="科室主要挂牌" prop="name">
                <el-input v-model="addHospatilObject.mainDepartmentListing"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item    label="科室负责人" prop="name">
                <el-input v-model="addHospatilObject.headMan"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">

              <el-form-item    label="项目关键科室" prop="name">
                <el-input v-model="addHospatilObject.projectKeyDepartment"></el-input>
              </el-form-item>
            </el-col>
            </el-row>

            <el-row>
              <el-col :span="6">

                <el-form-item    label="分管领导" prop="name">
                  <el-input v-model="addHospatilObject.leader"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item    label="经销商" prop="number" >
                  <el-input type="text" v-model="addHospatilObject.dealer"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item style="font-weight: bolder"   label="经销商负责人" prop="number" >
                  <el-input type="text" v-model="addHospatilObject.dealerHeadMan"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item style="font-weight: bolder"   label="电话" prop="number" >
                  <el-input type="number" v-model="addHospatilObject.phone"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
          <el-form :inline="true" :model="addHospatilObject" >
            <el-form-item style="font-weight: bolder"   label="第一次拜访时间" prop="number" >
              <el-date-picker
                  v-model="addHospatilObject.fristCountTime"
                  type="date"
                  placeholder="请选择日期">
              </el-date-picker>
            </el-form-item>
            <el-form-item style="font-weight: bolder"   label="医院有无相关产品" prop="name">
              <el-switch
                  v-model="addHospatilObject.fightFlag"
                  active-color="#13ce66"
                  ref="upload"
                  active-value="1"
                  inactive-value="0"
                  inactive-text="无"
                  active-text="有"
                  inactive-color="#ff4949">
              </el-switch>
            </el-form-item>
          </el-form>
          <el-form  :model="addHospatilObject"   ref="ruleForm" label-width="180px" class="demo-ruleForm">
            <el-form-item style="font-weight: bolder"   label="项目有无竞品和基本情况" prop="name">
              <el-input v-model="addHospatilObject.fightInformation" type="textarea"></el-input>
            </el-form-item>
            <el-form-item label="科室照片">
              <el-upload
                  v-model:file-list="fileList"
                  :action="uploadIp"
                  list-type="picture-card"
                  :on-success="handleSuccess"
                  :headers="token1"
                  :auto-upload="false"
                  ref="uploadRef"
                  :on-error="handleSuccess"
              >
                <el-icon><Plus /></el-icon>
              </el-upload>
            </el-form-item>
          </el-form>
          <div>
              <el-button type="info" @click="addHospital=false" >取消</el-button>
              <el-button type="primary" @click="conAddHospital">确认</el-button>
          </div>
      </el-dialog>
    </div>
    <div id="addOutSidePlanDiaLog">
      <el-dialog fullscreen v-model="addOutSidePlanFlag" title="添加出差计划">
        <div style="width: 100%">
          <el-form inline v-model="addOutSidePlanObject">
          <el-form-item label="申请人" >
            <el-input v-model.trim="addOutSidePlanObject.fromManName" disabled/>
          </el-form-item>
          <el-form-item label="岗位" >
            <el-input v-model.trim="addOutSidePlanObject.postName" disabled/>
          </el-form-item>
        </el-form>
        </div>
        <el-button type="primary" style="float: left" @click="addDateWork()">添加工作日期</el-button>
        <div style="width: 10% "  v-for="(domain, index) in addOutSidePlanObject.datePlan" :key="domain.date">
          <el-form  v-model="addOutSidePlanObject" inline label-width="auto" >
            <el-form-item>
              <span class="demonstration" style="">工作日期:</span>
              <el-date-picker v-model="domain.date" type="date" placeholder="请选择日期" :size="size" value-format="YYYY-MM-DD"/>
            </el-form-item>
            <div v-for="(item, index2) in domain.times" :key="item.period" style="width: 180vh;text-align: left">
            <el-form v-model="domain.times" inline>
                <el-form-item  label="工作时段">
                  <el-select v-model="item.period" placeholder="请选择工作时段">
                    <el-option label="上午" value="上午" />
                    <el-option label="下午" value="下午" />
                  </el-select>
                </el-form-item>
                <el-form-item label="拜访单位">
                  <el-input v-model.trim="item.unit"></el-input>
                </el-form-item>
                <el-form-item label="拜访科室">
                  <el-input v-model.trim="item.offices"></el-input>
                </el-form-item>
                <el-form-item label="拜访人物">
                  <el-input v-model.trim="item.character"></el-input>
                </el-form-item>
              <el-form-item label="交通工具">
                <el-select v-model="item.transportation" placeholder="请选择交通工具">
                  <el-option label="飞机" value="飞机" />
                  <el-option label="高铁" value="高铁" />
                  <el-option label="火车" value="火车" />
                  <el-option label="客车" value="客车" />
                  <el-option label="自驾" value="自驾" />
                  <el-option label="其他" value="其他" />
                </el-select>
              </el-form-item>
            </el-form>
              <div class="target" style="text-align: left">
                <el-form v-model="domain.times">
                  <el-form-item label="拜访目的">
                    <el-input v-model.trim="item.objective" type="textarea" ></el-input>
                  </el-form-item>
                </el-form>
              </div>
            </div>
          </el-form>
          <el-button type="primary" @click="addTimeWork(index,index2)">添加时段和工作内容</el-button>
        </div>
        <el-button size="large" type="info" @click="addOutSidePlanFlag =false">返回</el-button>
        <el-button size="large" type="primary" @click="outSidePlanSubmit()">提交</el-button>
      </el-dialog>
    </div>
    <div id="aaddDealerBaseInfoDialog">
      <el-dialog v-model="addDealerBaseInfoFlag" fullscreen title="添加经销商基本信息">
        <div v-for="(item,index) in addDealerBaseInfoObject" class="addDealerBaseInfoBox">
          <p style="text-align: left">序号:{{index+1}}</p>
          <el-form :model="item" label-width="120px">
            <el-row>
              <el-col :span="6">
                <el-form-item style="font-weight: bolder"   label="公司名称" prop="name">
                  <el-input v-model="item.dealerName"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item style="font-weight: bolder"   label="成立时间" prop="name">
                  <el-date-picker v-model="item.createTime" type="date" placeholder="请选择日期" :size="size" value-format="YYYY-MM-DD"/>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item style="font-weight: bolder"   label="公司地址" prop="name">
                  <el-input v-model="item.address"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item style="font-weight: bolder"   label="公司性质" prop="name">
                  <el-input v-model="item.companyNature"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="6">
                <el-form-item style="font-weight: bolder"   label="市场区域" prop="name">
                  <el-input v-model="item.marketArea"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item style="font-weight: bolder"   label="主营科室" prop="name">
                  <el-input v-model="item.mainDepartment"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item style="font-weight: bolder"   label="主营产品" prop="name">
                  <el-input v-model="item.mainProducts"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-button size="default" type="success" @click="addestimate(index)">添加该经销商评估</el-button>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="6">
                <el-form-item style="font-weight: bolder"   label="对接人姓名" prop="name">
                  <el-input v-model="item.contactPersonName"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item style="font-weight: bolder"   label="职务" prop="name">
                  <el-input v-model="item.post"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item style="font-weight: bolder"   label="联系方式" prop="name">
                  <el-input v-model="item.phone"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <div v-if="item.estimate.length >0">已填写评估</div>
              </el-col>


            </el-row>
          </el-form>
        </div>
        <el-button size="large" type="success" @click="addDealerBaseInfoOne">添加经销商</el-button>
        <el-button size="large" type="info" @click="addDealerBaseInfoFlag =false">返回</el-button>
        <el-button size="large" type="primary" @click="dealerBaseInfoSubmit()">提交</el-button>
      </el-dialog>
    </div>
    <div id="addChannelBaseInfoDialog">
      <el-dialog v-model="addChannelBaseInfoFlag" fullscreen title="添加渠道初筛汇总">
        <el-form :model="addChannelBaseInfoObject" label-width="120px">
          <el-row>
            <el-col :span="6">
              <el-form-item label="省市" >
                <el-input v-model.trim="addChannelBaseInfoObject.provinceCity"/>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="中标单位名称" >
                <el-input v-model.trim="addChannelBaseInfoObject.winningBidderName"/>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="招投标时间" >
                <el-input v-model.trim="addChannelBaseInfoObject.biddingTime"/>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="采购单位" >
                <el-input v-model.trim="addChannelBaseInfoObject.purchasingUnit"/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="采购项目名称" >
                <el-input v-model.trim="addChannelBaseInfoObject.procurementProjectName"/>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="采购设备名称" >
                <el-input v-model.trim="addChannelBaseInfoObject.procurementEquipmentName"/>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="预算金额" >
                <el-input v-model.trim="addChannelBaseInfoObject.budgetAmount"/>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="中标金额" >
                <el-input v-model.trim="addChannelBaseInfoObject.winningAmount"/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">

              <el-form-item label="信息来源平台" >
                <el-input v-model.trim="addChannelBaseInfoObject.informationSourcePlatform"/>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="信息链接" >
                <el-input v-model.trim="addChannelBaseInfoObject.informationLink"/>
              </el-form-item>
            </el-col>
            <el-col :span="6"></el-col>
            <el-col :span="6"></el-col>
          </el-row>
        </el-form>
        <el-button size="large" type="info" @click="addChannelBaseInfoFlag =false">返回</el-button>
        <el-button size="large" type="primary" @click="channelBaseInfoSubmit()">提交</el-button>
      </el-dialog>
    </div>
    <div id="addDealerEvaluationDialog">
      <el-dialog v-model="addDealerEvaluationFlag" fullscreen title="添加经销商评估">
        <el-form :model="addDealerEvaluationObject" label-width="120px">
          <el-row>
            <el-col :span="6">
              <el-form-item label="经销商名称:">
                <el-input v-model.trim="addDealerEvaluationObject.dealerName" />
             </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="地址:">
                <el-input v-model.trim="addDealerEvaluationObject.address" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="经销区域:">
                <el-input v-model.trim="addDealerEvaluationObject.region" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="主要负责人:">
                <el-input v-model.trim="addDealerEvaluationObject.director" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="3">
              <el-form-item label="联系电话:">
                <el-input v-model.trim="addDealerEvaluationObject.phone" />
              </el-form-item>
            </el-col>
            <el-col :span="3">
              <el-form-item label="公司员工总计:">
                <el-input v-model.trim="addDealerEvaluationObject.workManNUmber" />
              </el-form-item>
            </el-col>
            <el-col :span="3">
              <el-form-item label="销售队伍:">
                <el-radio-group v-model="addDealerEvaluationObject.saleTeam" class="ml-4">
                  <el-radio label="0">无</el-radio>
                  <el-radio label="1">有</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="3">
              <el-form-item label="销售人员:">
                <el-input v-model.trim="addDealerEvaluationObject.saleManNumber" placeholder="销售人数"/>
              </el-form-item>
            </el-col>
            <el-col :span="3">
              <el-form-item label="合作客户:">
                <el-input v-model.trim="addDealerEvaluationObject.customerNumber" placeholder="合作客户数" />
              </el-form-item>
            </el-col>
            <el-col :span="3">
              <el-form-item label="三甲医院:">
                <el-input v-model.trim="addDealerEvaluationObject.sanjia" />
              </el-form-item>
            </el-col>
            <el-col :span="3">
              <el-form-item label="二甲医院:">
                <el-input v-model.trim="addDealerEvaluationObject.erjia" />
              </el-form-item>
            </el-col>
            <el-col :span="3">
              <el-form-item label="其他医院:">
                <el-input v-model.trim="addDealerEvaluationObject.outher" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-form-item label="当前经营主要产品:" label-width="130">
            <el-input v-model.trim="addDealerEvaluationObject.products" type="textarea"/>
          </el-form-item>
        </el-form>
        <div>
          <el-table :data="addDealerEvaluationObject.tableData" style="width: 100%">
            <el-table-column label="序号" prop="num"></el-table-column>
            <el-table-column label="项目" prop="project"></el-table-column>
            <el-table-column label="主要内容及各项分数" prop="infoandfen" width="800">
              <template #default="{ row }">
                <el-table :data="row['infoandfen']" >
                  <el-table-column prop="content"></el-table-column>
                </el-table>
              </template>
            </el-table-column>
            <el-table-column label="分值" prop="fen" width="200">
              <template #default="{ row }">
                <el-table :data="row['fen']" >
                  <el-table-column prop="content" label=""></el-table-column>
                </el-table>
              </template>
            </el-table-column>
            <el-table-column label="评分">
              <template #default="{ row }">
                <div class="dafen">
                <el-input v-for="(item,index) in addDealerEvaluationObject.tableData[0].da" v-model.trim="addDealerEvaluationObject.tableData[0].da[index]" placeholder="请输入评分" :maxlength="1" @input="handleInputfen(addDealerEvaluationObject.tableData,0,index)"></el-input>
              </div>
              </template>
            </el-table-column>
            <el-table-column label="综合分" prop="sum">
                <template #default="{ row }">
                  <div class="dafen">
                <el-input  v-model.trim="addDealerEvaluationObject.tableData[0].sum" placeholder="请输入评分" :maxlength="5"  @input="handleInput(row)"></el-input>
                  </div>
                </template>

            </el-table-column>
          </el-table>
          <el-table :data="addDealerEvaluationObject.tableData2" style="width: 100%">
            <el-table-column label="" prop="num"></el-table-column>
            <el-table-column label="" prop="project"></el-table-column>
            <el-table-column label="" prop="infoandfen" width="800">
              <template #default="{ row }">
                <el-table :data="row['infoandfen']" >
                  <el-table-column prop="content"></el-table-column>
                </el-table>
              </template>
            </el-table-column>
            <el-table-column label="" prop="fen" width="200">
              <template #default="{ row }">
                <el-table :data="row['fen']" >
                  <el-table-column prop="content" label=""></el-table-column>
                </el-table>
              </template>
            </el-table-column>
            <el-table-column label="">
              <template #default="{ row }">
                <div class="dafen">
                  <el-input v-for="(item,index) in addDealerEvaluationObject.tableData2[0].da" v-model.trim="addDealerEvaluationObject.tableData2[0].da[index]" placeholder="请输入评分" :maxlength="1" @input="handleInputfen(addDealerEvaluationObject.tableData2,0,index)"></el-input>
                </div>
              </template>
            </el-table-column>
            <el-table-column label="" prop="sum">
              <template #default="{ row }">
                <div class="dafen">
                  <el-input  v-model.trim="addDealerEvaluationObject.tableData2[0].sum" placeholder="请输入评分" :maxlength="5"  @input="handleInput(row)"></el-input>
                </div>
              </template>

            </el-table-column>
          </el-table>
          <el-table :data="addDealerEvaluationObject.tableData3" style="width: 100%">
            <el-table-column label="" prop="num"></el-table-column>
            <el-table-column label="" prop="project"></el-table-column>
            <el-table-column label="" prop="infoandfen" width="800">
              <template #default="{ row }">
                <el-table :data="row['infoandfen']" >
                  <el-table-column prop="content"></el-table-column>
                </el-table>
              </template>
            </el-table-column>
            <el-table-column label="" prop="fen" width="200">
              <template #default="{ row }">
                <el-table :data="row['fen']" >
                  <el-table-column prop="content" label=""></el-table-column>
                </el-table>
              </template>
            </el-table-column>
            <el-table-column label="">
              <template #default="{ row }">
                <div class="dafen">
                  <el-input v-for="(item,index) in addDealerEvaluationObject.tableData3[0].da" v-model.trim="addDealerEvaluationObject.tableData3[0].da[index]" placeholder="请输入评分" :maxlength="1" @input="handleInputfen(addDealerEvaluationObject.tableData3,0,index)"></el-input>
                </div>
              </template>
            </el-table-column>
            <el-table-column label="" prop="sum">
              <template #default="{ row }">
                <div class="dafen">
                  <el-input  v-model.trim="addDealerEvaluationObject.tableData3[0].sum" placeholder="请输入评分" :maxlength="5"  @input="handleInput(row)"></el-input>
                </div>
              </template>

            </el-table-column>
          </el-table>
          <el-table :data="addDealerEvaluationObject.tableData4" style="width: 100%">
            <el-table-column label="" prop="num"></el-table-column>
            <el-table-column label="" prop="project"></el-table-column>
            <el-table-column label="" prop="infoandfen" width="800">
              <template #default="{ row }">
                <el-table :data="row['infoandfen']" >
                  <el-table-column prop="content"></el-table-column>
                </el-table>
              </template>
            </el-table-column>
            <el-table-column label="" prop="fen" width="200">
              <template #default="{ row }">
                <el-table :data="row['fen']" >
                  <el-table-column prop="content" label=""></el-table-column>
                </el-table>
              </template>
            </el-table-column>
            <el-table-column label="">
              <template #default="{ row }">
                <div class="dafen">
                  <el-input v-for="(item,index) in addDealerEvaluationObject.tableData4[0].da" v-model.trim="addDealerEvaluationObject.tableData4[0].da[index]" placeholder="请输入评分" :maxlength="2" @input="handleInputfen(addDealerEvaluationObject.tableData4,0,index)"></el-input>
                </div>
              </template>
            </el-table-column>
            <el-table-column label="" prop="sum">
              <template #default="{ row }">
                <div class="dafen">
                  <el-input  v-model.trim="addDealerEvaluationObject.tableData4[0].sum" placeholder="请输入评分" :maxlength="5"  @input="handleInput(row)"></el-input>
                </div>
              </template>

            </el-table-column>
          </el-table>
        </div>
        <el-form :model="addDealerEvaluationObject" label-width="120px">
          <div style="text-align: center;margin: 1rem 0">综合评价</div>
            <el-input v-model.trim="addDealerEvaluationObject.comprehensiv" type="textarea" placeholder="请填写综合评价"></el-input>
        </el-form>
        <div style="margin-top: 1rem">
          <el-button size="large" type="info" @click="addDealerEvaluationFlag =false">返回</el-button>
          <el-button size="large" type="primary" @click="adddealerEvaluationSubmit()">确定</el-button>
        </div>
      </el-dialog>
    </div>
    <div id="addProjectScheduleDialog">
      <el-dialog v-model="addProjectScheduleFlag" fullscreen title="客观分析项目进度">
        <el-form :model="addProjectScheduleObject" label-width="120px">
          <div v-for="item in addProjectScheduleObject">
              <el-form-item label="日期">
                <el-date-picker v-model="item.date" type="date" placeholder="请选择日期" :size="size" value-format="YYYY-MM-DD"/>
              </el-form-item>
            <el-form-item label="医院名称">
              <el-input v-model.trim="item.hospitalName" />
            </el-form-item>
            <el-form-item label="科室名称">
              <el-input v-model.trim="item.deptName" />
            </el-form-item>
            <el-form-item label="负责人">
              <el-input v-model.trim="item.director" />
            </el-form-item>
            <el-form-item label="联系电话">
              <el-input v-model.trim="item.phone" />
            </el-form-item>
            <el-form-item label="是否可以立项">
              <el-input v-model.trim="item.isProject" />
            </el-form-item>
            <el-form-item label="立项名称">
              <el-input v-model.trim="item.projectName" />
            </el-form-item>
            <el-form-item label="重点阐述">
              <el-input v-model.trim="item.keynote" />
            </el-form-item>
          </div>
          <el-button type="primary" @click ="addNewProjectScheduleObject">添加项目进度</el-button>
        </el-form>
        <div style="margin-top: 1rem">
          <el-button size="large" type="info" @click="addProjectScheduleFlag =false">返回</el-button>
          <el-button size="large" type="primary" @click="addProjectScheduleSubmit()">提交</el-button>
        </div>
      </el-dialog>
    </div>
    <div id="addRegionalHospitalDialog">
      <el-dialog v-model="addRegionalHospitalFlag" fullscreen title="地区医院信息">
        <el-form class="add_form" :model="addRegionalHospitalObject" label-width="200px">
          <div>
            <el-form-item label="城市名称">
              <el-input class="long_input" v-model:value="addRegionalHospitalObject.cityName"></el-input>
            </el-form-item>
          </div>
          <div>
            <el-form-item label="总人口数">
              <el-input v-model:value="addRegionalHospitalObject.sunPeoples"></el-input>
            </el-form-item>
            <el-form-item label="GDP省内排名">
              <el-input v-model:value="addRegionalHospitalObject.topGdp"></el-input>
            </el-form-item>
          </div>
          <div>
            <el-form-item label="城区人口">
              <el-input v-model:value="addRegionalHospitalObject.cityNumber"></el-input>
            </el-form-item>
            <el-form-item label="支柱产业">
              <el-input v-model:value="addRegionalHospitalObject.pillar"></el-input>
            </el-form-item>
          </div>
          <div>
            <table class="add_table">
              <tr>
                <td>医院类别</td>
                <td>医院名称</td>
                <td>地址</td>
                <td></td>
              </tr>
              <tr v-for="(item,index) in addRegionalHospitalObject.leadHospitals">
                <td>{{ index == 0?'带头综合医院':'' }}</td>
                <td><el-input v-model:value="item.name"></el-input></td>
                <td><el-input v-mode:value="item.address"></el-input></td>
                <td>
                  <el-button v-show="index == 0" @click="addRegional_addHospital()">+</el-button>
                </td>
              </tr>
            </table>
          </div>
          <div>
            <table class="add_table">
              <tr v-for="(item,index) in addRegionalHospitalObject.thirdHospital">
                <td>{{ index == 0?'三级医院':'' }}</td>
                <td><el-input v-model:value="item.name"></el-input></td>
                <td><el-input v-mode:value="item.address"></el-input></td>
                <td>
                  <el-button v-show="index == 0" @click="addRegional_addThridHospital()">+</el-button>
                </td>
              </tr>
            </table>
          </div>
          <div>
            <table class="add_table">
              <tr v-for="(item,index) in addRegionalHospitalObject.leadingSpiritHospitals">
                <td>{{ index == 0?'带头专科医院':'' }}</td>
                <td><el-input v-model:value="item.name"></el-input></td>
                <td><el-input v-mode:value="item.address"></el-input></td>
                <td>
                  <el-button v-show="index == 0" @click="">+</el-button>
                </td>
              </tr>
            </table>
          </div>
          <div>
            <table class="add_table">
              <tr v-for="(item,index) in addRegionalHospitalObject.psychiatryHospitals">
                <td>{{ index == 0?'精神专科医院':'' }}</td>
                <td><el-input v-model:value="item.name" ></el-input></td>
                <td><el-input v-mode:value="item.address"></el-input></td>
                <td>
                  <el-button v-show="index == 0" @click="">+</el-button>
                </td>
              </tr>
            </table>
          </div>
          <div>
            <el-form-item label="地区精神心理协会及近期动向">
              <el-input class="long_input" v-model:value="addRegionalHospitalObject.recentTrends" />
            </el-form-item>
          </div>

          <div>
          <el-form-item label="地区心理健康服务项目">
            <el-input class="long_input" v-model:value="addRegionalHospitalObject.healthServiceProjectsArea" />
          </el-form-item>
          </div>
          <div>
          <el-form-item label="地区社区心理相关工作">
            <el-input class="long_input" v-model:value="addRegionalHospitalObject.psychologicalRelatedWork" />
          </el-form-item>
          </div>
          <div>
          <el-form-item label="医院心理健康服务项目">
            <el-input class="long_input" v-model:value="addRegionalHospitalObject.healthServiceProjectsHospital" />
          </el-form-item>
          </div>
          <div>
          <el-form-item label="医院心理相关学术科研">
            <el-input class="long_input" v-model:value="addRegionalHospitalObject.research" />
          </el-form-item>
          </div>
        </el-form>
        <div style="margin-top: 1rem">
          <el-button size="large" type="info" @click="addRegionalHospitalFlag =false">返回</el-button>
          <el-button size="large" type="primary" @click="addRegionalHospitalSubmit()">提交</el-button>
        </div>
      </el-dialog>
    </div>
    <div id="addObjectProjectDialog">
      <el-dialog v-model="addObjectProjectFlag" fullscreen title="项目进度跟进">
        <el-form :model="addObjectProjectObject" inline="true"  v-for="(item,index) in addObjectProjectObject">
          <el-row>
            <el-col :span="8">
              <el-form-item label=" 区 域">
                <el-input v-model:value="item.region"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="地级市">
                <el-input  v-model:value="item.provincialCity"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="医院名称">
                <el-input  v-model:value="item.hospitalName"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="拜访时间" >
                <el-date-picker v-model="item.visitTime" type="date" placeholder="请选择日期" value-format="YYYY-MM-DD"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="项目阶段">
                <el-input v-model:value="item.projectStage"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="拜访人">
                <el-input v-model:value="item.visitor" ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="医院人员">
                <el-input  v-model:value="item.hospitalStaffContact"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="姓名电话">
                <el-input v-model:value="item.phone"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="坐诊时间">
                <el-date-picker v-model="item.clinicTime" type="date" placeholder="请选择日期" value-format="YYYY-MM-DD"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="经销商名称">
                <el-input  v-model:value="item.dealerCompanyName"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="拜访目标">
                <el-input v-model:value="item.visitObjective"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="沟通内容">
                <el-input  v-model:value="item.communicationContent"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col ::span="24">
              <div style="width: 80%;margin: 1rem auto">
                <span style="text-align: center">拜访结果</span>
                <el-input v-model:value="item.visitResult" type="textarea"></el-input>
              </div>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="12">
              <el-form-item label="主要问题">
                <el-input  v-model:value="item.mainIssues"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="预计下次拜访时间">
                <el-date-picker v-model="item.expectedNextVisitTime" type="date" placeholder="请选择日期" value-format="YYYY-MM-DD"/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="24">
              <div style="width: 80%;margin: 1rem auto">
                <span style="text-align: center">下一步计划</span>
                <el-input v-model:value="item.nextStepPlan" type="textarea"></el-input>
              </div>
            </el-col>
          </el-row>
          <div style="margin: 1rem 0"></div>
        </el-form>
        <el-button type="success" @click="addObject_Project_one()">添加项目跟进</el-button>
        <div style="margin-top: 1rem">
          <el-button size="large" type="info" @click="addObjectProjectFlag =false">返回</el-button>
          <el-button size="large" type="primary" @click="addObjectProjectSubmit()">提交</el-button>
        </div>
      </el-dialog>
    </div>
    <div id="addmedicalInformationLogDiaLog">
      <el-dialog v-model="addmedicalInformationLogFlag" fullscreen title="添加医学信息官日志">
        <el-form v-model="addmedicalInformationObject">
          <el-row>
            <el-col :span="6">
              <el-form-item label="医院名称">
                <el-input v-model.trim="addmedicalInformationObject.hospitalName"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item  label="医院等级">
                <el-select v-model="addmedicalInformationObject.hospitalLv" placeholder="请选择等级">
                  <el-option label="三级特等" value="三级特等"></el-option>
                  <el-option label="三级甲等" value="三级甲等"></el-option>
                  <el-option label="三级乙等" value="三级乙等"></el-option>
                  <el-option label="三级丙等" value="三级丙等"></el-option>
                  <el-option label="二级甲等" value="二级甲等"></el-option>
                  <el-option label="二级乙等" value="二级乙等"></el-option>
                  <el-option label="二级丙等" value="二级丙等"></el-option>
                  <el-option label="一级甲等" value="一级甲等"></el-option>
                  <el-option label="一级乙等" value="一级乙等"></el-option>
                  <el-option label="一级丙等" value="一级丙等"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item  label="是否公立">
                <el-select v-model="addmedicalInformationObject.publicOrPrivate" placeholder="请选择等级">
                  <el-option label="是" value="是"></el-option>
                  <el-option label="否" value="否"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6" >
              <el-form-item  label="医联体归属">
                <el-input v-model.trim="addmedicalInformationObject.consortium " placeholder="医联体归属">
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item  label="帮扶或被帮扶情况">
                <el-input v-model.trim="addmedicalInformationObject.Support " placeholder="帮扶或被帮扶情况">
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item  label="信息化能力">
                <el-input v-model.trim="addmedicalInformationObject.informatization " placeholder="信息化能力">
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item  label="门诊量">
                <el-input v-model.trim="addmedicalInformationObject.outpatient" placeholder="门诊量">
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item  label="重点科室">
                <el-input v-model.trim="addmedicalInformationObject.keynote " placeholder="重点科室">
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item  label="拜访科室名">
                <el-input v-model.trim="addmedicalInformationObject.visitDept " placeholder="拜访科室名">
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item  label="拜访医务人员">
                <el-input v-model.trim="addmedicalInformationObject.visitDoctor " placeholder="拜访科室名">
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item  label="科室成立时间">
                <el-date-picker
                    v-model="addmedicalInformationObject.creatTime"
                    type="date"
                    placeholder="选择成立时间"
                    :size="size"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item  label="科室病床数">
                <el-input v-model.trim="addmedicalInformationObject.deptBadNumber " placeholder="科室病床数">
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <div style="width: 45% ;display: inline-block;padding: 1rem" >
              <span style="font-weight: bolder">科室人员结构</span>
              <el-input v-model.trim="addmedicalInformationObject.deptPost" type="textarea" placeholder="科室人员结构"></el-input>
          </div>
          <div style="width: 45%;display: inline-block;padding: 1rem">
            <span style="font-weight: bolder">科室已购设备</span>
            <el-input v-model.trim="addmedicalInformationObject.deptBuy " type="textarea" placeholder="科室已购设备"></el-input>
          </div>
          <div style="width: 92%;display: inline-block;padding: 1rem">
            <span style="font-weight: bolder">初步立项综述</span>
            <el-input v-model.trim="addmedicalInformationObject.addProject " type="textarea" placeholder="初步立项综述"></el-input>
          </div>
          <div style="width: 92%;display: inline-block;padding: 1rem">
            <span style="font-weight: bolder">地区汇总分析</span>
            <el-input v-model.trim="addmedicalInformationObject.areaAnalysis " type="textarea" placeholder="初步立项综述"></el-input>
          </div>
          <el-form-item label="科室照片">
            <el-upload
                v-model:file-list="fileList2"
                :action="uploadIp"
                list-type="picture-card"
                :on-success="handleSucces2"
                :headers="token1"
                :auto-upload="false"
                ref="uploadRef2"
                :on-error="handleSucces2"
            >
              <el-icon><Plus /></el-icon>
            </el-upload>
          </el-form-item>
        </el-form>
        <div style="margin-top: 1rem">
          <el-button size="large" type="info" @click="addmedicalInformationLogFlag =false">返回</el-button>
          <el-button size="large" type="primary" @click="addmedicalInformationLogSubmit()">提交</el-button>
        </div>
      </el-dialog>
    </div>
    <div id="addChannelLogDiaLog">
      <el-dialog v-model="addChannelLogFlag" fullscreen title="渠道工作日志">
        <el-form v-model="addChannelLogObject">
          <el-row>
            <el-col :span="8">
              <el-form-item label="拜访单位">
                <el-input v-model.trim="addChannelLogObject.visitUnit"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-col :span="8">
                <el-form-item label="拜访科室">
                  <el-input v-model.trim="addChannelLogObject.visitDept"></el-input>
                </el-form-item>
              </el-col>
            </el-col>
            <el-col :span="8">
              <el-col :span="8">
                <el-form-item label="拜访人员">
                  <el-input v-model.trim="addChannelLogObject.visitMan"></el-input>
                </el-form-item>
              </el-col>
            </el-col>
          </el-row>
          <div style="width: 92%;display: inline-block;padding: 1rem">
            <span style="font-weight: bolder">目的</span>
            <el-input v-model.trim="addChannelLogSubmit.target " type="textarea" placeholder="目的" :autosize="{minRows:20}"></el-input>
          </div>
          <div style="margin-top: 1rem">
            <el-button size="large" type="info" @click="addChannelLogFlag =false">返回</el-button>
            <el-button size="large" type="primary" @click="addChannelLogSubmit()">提交</el-button>
          </div>
        </el-form>
      </el-dialog>
    </div>
    <div id="addPreSalesEngineerLogDialog">
      <el-dialog v-model="addPreSalesEngineerLogFlag" fullscreen title="售前工程师日志">
        <el-form v-model="addPreSalesEngineerObject">
          <el-row>
            <el-col :span="8">
              <el-form-item label="拜访单位">
                <el-input v-model.trim="addPreSalesEngineerObject.visitUnit"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-col :span="8">
                <el-form-item label="拜访科室">
                  <el-input v-model.trim="addPreSalesEngineerObject.visitDept"></el-input>
                </el-form-item>
              </el-col>
            </el-col>
            <el-col :span="8">
              <el-col :span="8">
                <el-form-item label="拜访人员">
                  <el-input v-model.trim="addPreSalesEngineerObject.visitMan"></el-input>
                </el-form-item>
              </el-col>
            </el-col>
          </el-row>
        </el-form>
        <div style="width: 92%;display: inline-block;padding: 1rem">
          <span style="font-weight: bolder">拜访目的</span>
          <el-input v-model.trim="addPreSalesEngineerObject.target " type="textarea" placeholder="拜访目的" :autosize="{minRows:6}"></el-input>
        </div>
        <div style="width: 92%;display: inline-block;padding: 1rem">
          <span style="font-weight: bolder">本次效果</span>
          <el-input v-model.trim="addPreSalesEngineerObject.effect " type="textarea" placeholder="本次效果" :autosize="{minRows:6}"></el-input>
        </div>
        <div style="width: 92%;display: inline-block;padding: 1rem">
          <span style="font-weight: bolder">需求汇总</span>
          <el-input v-model.trim="addPreSalesEngineerObject.pool " type="textarea" placeholder="需求汇总" :autosize="{minRows:6}"></el-input>
        </div>
        <div style="width: 92%;display: inline-block;padding: 1rem">
          <span style="font-weight: bolder">综合分析</span>
          <el-input v-model.trim="addPreSalesEngineerObject.analysis " type="textarea" placeholder="综合分析" :autosize="{minRows:6}"></el-input>
        </div>
        <div style="margin-top: 1rem">
          <el-button size="large" type="info" @click="addPreSalesEngineerLogFlag =false">返回</el-button>
          <el-button size="large" type="primary" @click="addPreSalesEngineerSubmit()">提交</el-button>
        </div>
      </el-dialog>
    </div>
  </div>
</template>
<script setup lang="ts">
import { onMounted, ref } from "vue";
import {
  getprocesslists
} from "../../api/flow";
import { submitLaunch } from "../../api/task";
import { ElMessage } from "element-plus";
import { addOutSideVue, getAddInfo } from "../../api/function";
import { format } from "date-fns";
import {useUsersStore} from "../../store/userInfo.ts";
const uploadIp = import.meta.env.VITE_HTTP+"/system/upload/file"
const pageSize = ref(10);
const pageNum = ref(1);
const store = useUsersStore();
const { name, role, token } = store;
const token1 = {
  token: store.token,
}
const pageInfo = ref([]);
const total =ref(0);
const lookflag = ref(false);
const  fileList = ref<UploadUserFile[]>([])
const  fileList2 = ref<UploadUserFile[]>([])
const uploadRef = ref<UploadInstance>()
const uploadRef2 = ref<UploadInstance>()

const addobject = ref({
  sysUserName: '',
  sysDeptName: '',
  sysUserid: '',
  sysDeptid: '',
  planeFlag: '',
  agreeFlag: '',
  departureTime: '',
  returnTime: '',
  evectionType: '',
  departurePlace: '',
  destinationPlace: '',
  evectionProject: '',
  evectionTarget: '',
  transportation: '',
  togetherMan: '',
  fromMan: '',
  deptLeader: '',
  job: ''
});
const addHospatilObject = ref({
  fileList: []
});
const addoutSide = ref(false);
const addHospital = ref(false);
const addOutSidePlanFlag = ref(false);
const addOutSidePlanObject = ref({
  post: '',
  fromMan: '',
  fromManName: '',
  sysDeptName: '',
  sysDeptid: '',
  postName: '',
  datePlan: [{
    date: '',
    times: [
      {
        period: '',
        unit: '',
        offices: '',
        character: '',
        objective: '',
        transportation: ''
      }
    ]
  }]
});
const addDealerBaseInfoFlag = ref(false);
const addDealerBaseInfoObject=ref([
    { estimate:{
        region : '',
        director : '',
        phone : '',
        workManNUmber : '',
        saleTeam : '',
        saleManNumber : '',
        customerNumber : '',
        sanjia : '',
        erjia : '',
        outher : '',
        products : '',
        comprehensiv : '',
        tableData:[{
          num: 1,
          project: '价值取向（20分）',
          'infoandfen': [
            {content: '1、认同、支持公司经营理念和名牌战略'},
            {content: '2、遵循公司的价格和市场管理策略'},
            {content: '3、是否愿意与公司保持稳定的经销关系'},
            {content: '4、不经营与公司产品有明显竞争性质的产品'},
            {content: '5、在所有经营产品中，把公司产品作为主营产品'},
            {content: '6、资信程度高，能遵循公司现款现货的原则'},
            {content: '7、同公司保持良好的沟通，与公司保持同步发展'},
            {content: '8、能主动及时处理或协同公司处理客户的异议'},
            {content: '9、整个团队诚实可信，在当地有着良好的声誉'},
          ],
          fen: [
            {content: 3},
            {content: 3},
            {content: 2},
            {content: 2},
            {content: 2},
            {content: 2},
            {content: 2},
            {content: 2},
            {content: 1},
          ],
          da: ['', '', '', '', '', '', '', '', '',],
          sum: '',
        }],
        tableData2:[{
          num: 2,
          project: '经营能力（30分）',
          'infoandfen': [
            { content: '10、具有良好的经销网络' },
            { content: '11、有专职的销售队伍' },
            { content: '12、有充足的可供市场运作的资金' },
            { content: '13、具有一个高素质且团结奋进的良好团队' },
            { content: '14、同政府机关单位保持有良好的关系' },
            { content: '15、有电话、传真和电脑等通讯等办公设施，有良好的办公场所' },
            { content: '16、有丰富的市场营销经验和超前的经营意识' },
            { content: '17、权力集中、经营机制灵活，可以根据市场情况迅速做出反应' },
          ],
          fen: [
            { content: 6},
            { content: 4},
            { content: 5},
            { content: 2},
            { content: 2},
            { content: 2},
            { content: 2},
            { content: 2},
          ],
          da: ['', '', '', '', '', '', '', '' ,],
          sum: '',
        },],
        tableData3:[{
          num: 3,
          project: '积极性（15分）',
          'infoandfen': [
            { content: '18、能够根据市场的发展主动组织各项会销等市场活动' },
            { content: '19、积极配合公司的各项政策及要求，提供充足的人力和物力支持' },
            { content: '20、积极向公司提供各种合理化建议' },
            { content: '21、积极主动推广公司的各种产品' },
            { content: '22、积极配合公司的市场调研工作' },
          ],
          fen: [
            { content: 3},
            { content: 3},
            { content: 2},
            { content: 2},
            { content: 2},
          ],
          da: ['', '', '', '', '', ],
          sum: '',
        },],
        tableData4:[{
          num: 4,
          project: '销售业绩（15分）',
          'infoandfen': [
            { content: '近一年营业收入500万以下' },
            { content: '近一年营业收入500万-1000万' },
            { content: '近一年营业收入1000万-2000万' },
            { content: '近一年营业收入2000万以上' },
          ],
          fen: [
            { content: 3},
            { content: 5},
            { content: 10},
            { content: 15},
          ],
          da: ['', '', '', '', ],
          sum: '',
        }]
      },
      allflag :false,
    },
    ])
const addChannelBaseInfoFlag = ref(false);
const addChannelBaseInfoObject= ref({});
const addDealerEvaluationFlag = ref(false);
const addDealerEvaluationObject = ref({
  tableData:[{
    num: 1,
    project: '价值取向（20分）',
    'infoandfen': [
      {content: '1、认同、支持公司经营理念和名牌战略'},
      {content: '2、遵循公司的价格和市场管理策略'},
      {content: '3、是否愿意与公司保持稳定的经销关系'},
      {content: '4、不经营与公司产品有明显竞争性质的产品'},
      {content: '5、在所有经营产品中，把公司产品作为主营产品'},
      {content: '6、资信程度高，能遵循公司现款现货的原则'},
      {content: '7、同公司保持良好的沟通，与公司保持同步发展'},
      {content: '8、能主动及时处理或协同公司处理客户的异议'},
      {content: '9、整个团队诚实可信，在当地有着良好的声誉'},
    ],
    fen: [
      {content: 3},
      {content: 3},
      {content: 2},
      {content: 2},
      {content: 2},
      {content: 2},
      {content: 2},
      {content: 2},
      {content: 1},
    ],
    da: ['', '', '', '', '', '', '', '', '',],
    sum: '',
  }],
  tableData2:[{
    num: 2,
    project: '经营能力（30分）',
    'infoandfen': [
      { content: '10、具有良好的经销网络' },
      { content: '11、有专职的销售队伍' },
      { content: '12、有充足的可供市场运作的资金' },
      { content: '13、具有一个高素质且团结奋进的良好团队' },
      { content: '14、同政府机关单位保持有良好的关系' },
      { content: '15、有电话、传真和电脑等通讯等办公设施，有良好的办公场所' },
      { content: '16、有丰富的市场营销经验和超前的经营意识' },
      { content: '17、权力集中、经营机制灵活，可以根据市场情况迅速做出反应' },
    ],
    fen: [
      { content: 6},
      { content: 4},
      { content: 5},
      { content: 2},
      { content: 2},
      { content: 2},
      { content: 2},
      { content: 2},
    ],
    da: ['', '', '', '', '', '', '', '' ,],
    sum: '',
  },],
  tableData3:[{
    num: 3,
    project: '积极性（15分）',
    'infoandfen': [
      { content: '18、能够根据市场的发展主动组织各项会销等市场活动' },
      { content: '19、积极配合公司的各项政策及要求，提供充足的人力和物力支持' },
      { content: '20、积极向公司提供各种合理化建议' },
      { content: '21、积极主动推广公司的各种产品' },
      { content: '22、积极配合公司的市场调研工作' },
    ],
    fen: [
      { content: 3},
      { content: 3},
      { content: 2},
      { content: 2},
      { content: 2},
    ],
    da: ['', '', '', '', '', ],
    sum: '',
  },],
  tableData4:[{
    num: 4,
    project: '销售业绩（15分）',
    'infoandfen': [
      { content: '近一年营业收入500万以下' },
      { content: '近一年营业收入500万-1000万' },
      { content: '近一年营业收入1000万-2000万' },
      { content: '近一年营业收入2000万以上' },
    ],
    fen: [
      { content: 3},
      { content: 5},
      { content: 10},
      { content: 15},
    ],
    da: ['', '', '', '', ],
    sum: '',
  }],
  allflag:false
});
const imglink = ref('');
const checkUserList = ref([]);
const dept = ref({});
const exporttimes = ref('');
const user = ref({});
const addProjectScheduleFlag = ref(false);
const addProjectScheduleObject  =ref([{
  date:'',
}]);
const addRegionalHospitalFlag =ref(false);
const addRegionalHospitalObject =ref({
  cityName:'',
  sunPeoples:'',
  topGdp :'',
  cityNumber:'',
  pillar:'',
  leadHospitals:[{
    name:'',
    address:'',
  }],
  thirdHospital:[{
    name:'',
    address:'',
  }],
  leadingSpiritHospitals:[{
    name:'',
    address:'',
  }],
  psychiatryHospitals:[{
    name:'',
    address:'',
  }],
  recentTrends:'',
  healthServiceProjectsArea:'',
  psychologicalRelatedWork:'',
  healthServiceProjectsHospital:'',
  research:''
});
const addObjectProjectFlag = ref(false);
const addObjectProjectObject = ref([{
  region:'',
  provincialCity:'',
  hospitalName:'',
  visitTime:'',
  projectStage:'',
  visitor:'',
  hospitalStaffContact:'',
  Phone:'',
  clinicTime:'',
  dealerCompanyName:'',
  visitObjective:'',
  communicationContent:'',
  visitResult:'',
  mainIssues:'',
  nextStepPlan:'',
  expectedNextVisitTime:''
}]);
const addmedicalInformationLogFlag = ref(false);
const addmedicalInformationObject = ref({fileList:[]})
const addChannelLogFlag = ref(false);
const addChannelLogObject = ref({});
const addPreSalesEngineerLogFlag = ref(false);
const addPreSalesEngineerObject = ref({})

onMounted(async () => {
  await query();
});
const query = async () => {
  const res = await getprocesslists({ pageSize: pageSize.value, pageNum: pageNum.value });
  pageInfo.value = res.data.rows;
  total.value = res.data.total;
  console.log(res.data.rows);
};
const handleInput= async (row) => {
  row.sum = row.sum.replace(/[^\d]/g, '');
}
const handleInputfen = async (tableData, item, index) => {
  let sum = 0;
  tableData[item].da[index] = tableData[item].da[index].replace(/[^\d]/g, '');
  for (let i = 0; i < tableData[item].da.length; i++) {
    const value = parseInt(tableData[item].da[i]);
    if (!isNaN(value)) {
      sum += value;
    }
  }
  tableData[item].sum = sum;
};
const handleCurrentChange = async (val) => {
  pageNum.value = val;
  await query();
};
const lookmange = async (row) => {
  const res = await getAddInfo(null);
  imglink.value = row.id;
  dept.value = res.data.dept;
  user.value = res.data.user;
  switch (row.startFormKey) {
    case import.meta.env.VITE_OUTSIDE_Plan:
      addOutSidePlanObject.value.fromMan = user.value.userId;
      addOutSidePlanObject.value.fromManName = user.value.userName;
      addOutSidePlanObject.value.sysDeptName =  dept.value.deptName;
      addOutSidePlanObject.value.sysDeptid = user.value.deptId;
      addOutSidePlanObject.value.post = user.value.posts[0].postId;
      addOutSidePlanObject.value.postName = user.value.posts[0].postName;
      addOutSidePlanFlag.value = true;
      break;
    case import.meta.env.VITE_OUTSIDE_APPLAY:
      addobject.value = {};
      checkUserList.value = res.data.userlist;
      addobject.value.sysUserName = user.value.userName;
      addobject.value.sysUserid = user.value.userId;
      addobject.value.sysDeptName = dept.value.deptName;
      addobject.value.sysDeptid = user.value.deptId;
      addobject.value.fromMan = user.value.userName;
      addoutSide.value = true;
      break;
    case import.meta.env.VITE_HOSPITAL_INFO:
      addHospatilObject.value = {};
      addHospatilObject.value.fileList = []
      addHospital.value = true;
      addHospatilObject.value.sysUserName = user.value.userName;
      addHospatilObject.value.sysUserid = user.value.userId;
      addHospatilObject.value.sysDeptName = dept.value.deptName;
      addHospatilObject.value.sysDeptid = user.value.deptId;
      addHospatilObject.value.fromMan = user.value.userName;
      break;
    case import.meta.env.VITE_DEALER_BASE_INFO:
      addDealerBaseInfoObject.value.sysUserName = user.value.userName;
      addDealerBaseInfoObject.value.sysUserid = user.value.userId;
      addDealerBaseInfoObject.value.sysDeptName = dept.value.deptName;
      addDealerBaseInfoObject.value.sysDeptid = user.value.deptId;
      addDealerBaseInfoObject.value.fromMan = user.value.userName;
      addDealerBaseInfoFlag.value = true;
      break;
    case import.meta.env.VITE_CHANNEL_BASE_INFO:
      addChannelBaseInfoFlag.value =true;
      addChannelBaseInfoObject.value.sysUserName = user.value.userName;
      addChannelBaseInfoObject.value.sysUserid = user.value.userId;
      addChannelBaseInfoObject.value.sysDeptName = dept.value.deptName;
      addChannelBaseInfoObject.value.sysDeptid = user.value.deptId;
      addChannelBaseInfoObject.value.fromMan = user.value.userName;
      break;
    case import.meta.env.VITE_DEALER_EVALUATION:
      // addDealerEvaluationObject.value.sysUserName = user.value.userName;
      // addDealerEvaluationObject.value.sysUserid = user.value.userId;
      // addDealerEvaluationObject.value.sysDeptName = dept.value.deptName;
      // addDealerEvaluationObject.value.sysDeptid = user.value.deptId;
      // addDealerEvaluationObject.value.fromMan = user.value.userName;
      // addDealerEvaluationFlag.value =true;
      break;
    case import.meta.env.project_schedule:
      addProjectScheduleObject.value.sysUserName = user.value.userName;
      addProjectScheduleObject.value.sysUserid = user.value.userId;
      addProjectScheduleObject.value.sysDeptName = dept.value.deptName;
      addProjectScheduleObject.value.sysDeptid = user.value.deptId;
      addProjectScheduleObject.value.fromMan = user.value.userName;
      addProjectScheduleFlag.value = true;
      break;
    case  import.meta.env.VITE_REGIONAL_HOSPITAL:
      addRegionalHospitalObject.value.sysUserName = user.value.userName;
      addRegionalHospitalObject.value.sysUserid = user.value.userId;
      addRegionalHospitalObject.value.sysDeptName = dept.value.deptName;
      addRegionalHospitalObject.value.sysDeptid = user.value.deptId;
      addRegionalHospitalObject.value.fromMan = user.value.userName;
      addRegionalHospitalFlag.value =true;
      break;
    case  import.meta.env.VITE_OBJECTIVE_PROJECT:
      addObjectProjectFlag.value =true;
      break;
    default:
      ElMessage.error("暂不支持发起该流程");
  }
};
const conAddoutSide = async () => {
  const beginandend = exporttimes.value;
  if (!beginandend && beginandend.length !== 2) {
    ElMessage.error("请选择开始时间和结束时间");
    return;
  }
  const [beginTime, endTime] = beginandend.map((time) =>
      format(time, "yyyy-MM-dd HH:mm:ss")
  );
  addobject.value.departureTime = beginTime;
  addobject.value.returnTime = endTime;
  const jsonString = JSON.stringify(addobject.value);
  const res = await submitLaunch({
    processDefinitionKey: 'outside',
    formKey: import.meta.env.VITE_OUTSIDE_APPLAY,
    formData: jsonString
  });
  if (res.code == 200) {
    ElMessage.success(res.msg);
    addoutSide.value = false;
    await query();
  } else {
    ElMessage.error(res.msg);
  }
};
const conAddHospital = async () => {
  await uploadRef.value!.submit()
  const jsonString = JSON.stringify(addHospatilObject.value);
  const res = await submitLaunch({
    processDefinitionKey: 'hospital',
    formKey: import.meta.env.VITE_HOSPITAL_INFO,
    formData: jsonString
  });
  if (res.code == 200) {
    ElMessage.success(res.msg);
    addoutSide.value = false;
    await query();
  } else {
    ElMessage.error(res.msg);
  }
};
const addTimeWork = (i, j) => {
  const b = {
    period: '',
    unit: '',
    offices: '',
    character: '',
    objective: '',
    transportation: ''
  };

  addOutSidePlanObject.value.datePlan[i].times.push(b);
};
const addDateWork = () => {
  const b = {
    date: '',
    times: [
      {
        period: '',
        unit: '',
        offices: '',
        character: '',
        objective: '',
        transportation: ''
      }
    ]
  };
  addOutSidePlanObject.value.datePlan.push(b);
};
const outSidePlanSubmit = async () => {
  const jsonString = JSON.stringify(addOutSidePlanObject.value);
  const res = await submitLaunch({
    processDefinitionKey: 'outside',
    formKey: import.meta.env.VITE_OUTSIDE_Plan,
    formData: jsonString
  });
  if (res.code == 200) {
    ElMessage.success(res.msg);
    resetAddOutSidePlanObject();
    addOutSidePlanFlag.value = false;
    await query();
  } else {
    ElMessage.error(res.msg);
  }
};
const channelBaseInfoSubmit = async () => {
  const{provinceCity, winningBidderName, biddingTime, purchasingUnit, procurementProjectName, procurementEquipmentName, budgetAmount, winningAmount, informationSourcePlatform, informationLink,}=addChannelBaseInfoObject.value
  if (!provinceCity || !winningBidderName || !biddingTime || !purchasingUnit || !procurementProjectName || !procurementEquipmentName || !budgetAmount || !winningAmount || !informationSourcePlatform || !informationLink) {
    ElMessage.error("请将信息填写完整");
    return;
  }
  const jsonString = JSON.stringify(addChannelBaseInfoObject.value);
  const res = await submitLaunch({
    processDefinitionKey: 'channelbaseinfo',
    formKey: import.meta.env.VITE_CHANNEL_BASE_INFO,
    formData:jsonString
  });
  if (res.code == 200) {
    ElMessage.success(res.msg);
    addDealerBaseInfoObject.value={}
    addDealerBaseInfoFlag.value = false;
    await query();
  } else {
    ElMessage.error(res.msg);
  }
}
const dealerBaseInfoSubmit = async () => {
  // const {
  //   companyNature,
  //   marketArea,
  //   mainDepartment,
  //   mainProducts,
  //   contactPersonName,
  //   post,
  //   phone
  // } = addDealerBaseInfoObject.value;
  // if (!companyNature || !marketArea || !mainDepartment || !mainProducts || !contactPersonName || !post || !phone) {
  //   ElMessage.error("请将信息填写完整");
  //   return;
  // }
  console.log(addDealerBaseInfoObject.value);
  const jsonString = JSON.stringify(addDealerBaseInfoObject.value);
  const res = await submitLaunch({
    processDefinitionKey: 'dealerBaseInfo',
    formKey: import.meta.env.VITE_DEALER_BASE_INFO,
    formData: jsonString
  });
  if (res.code == 200) {
    ElMessage.success(res.msg);
    addDealerBaseInfoObject.value={}
    addDealerBaseInfoFlag.value = false;
    await query();
  } else {
    ElMessage.error(res.msg);
  }
}


const  addProjectScheduleSubmit = async() => {
  console.log(addProjectScheduleObject.value)
  const jsonString = JSON.stringify(addProjectScheduleObject.value);
  const res = await submitLaunch({
    processDefinitionKey: 'projectschedule',
    formKey: import.meta.env.VITE_PROJECT_SCHEDULE,
    formData: jsonString
  });
  if (res.code == 200) {
    ElMessage.success(res.msg);
    addProjectScheduleObject.value = [{date: ''}]
    addProjectScheduleFlag.value = false;
    await query();
  } else {
    ElMessage.error(res.msg);
  }
}
const addRegionalHospitalSubmit =async() => {
  const jsonString = JSON.stringify(addRegionalHospitalObject.value);
  const res = await submitLaunch({
    processDefinitionKey: 'regionalhospital',
    formKey: import.meta.env.VITE_REGIONAL_HOSPITAL,
    formData: jsonString
  });
  if (res.code == 200) {
    ElMessage.success(res.msg);
    addRegionalHospitalObject.value = [{
      cityName:'',
      sunPeoples:'',
      topGdp :'',
      cityNumber:'',
      pillar:'',
      leadHospitals:[],
      thirdHospital:[],
      leadingSpiritHospitals:[],
      psychiatryHospitals:[],
      recentTrends:'',
      healthServiceProjectsArea:'',
      psychologicalRelatedWork:'',
      healthServiceProjectsHospital:'',
      research:''
    }]
    addRegionalHospitalFlag.value = false;
    await query();
  } else {
    ElMessage.error(res.msg);
  }
}
const addObjectProjectSubmit = async ()=>{
  const jsonString = JSON.stringify(addObjectProjectObject.value);
  const res = await submitLaunch({
    processDefinitionKey: 'objectiveproject',
    formKey: import.meta.env.VITE_OBJECTIVE_PROJECT,
    formData: jsonString
  });
  if (res.code == 200) {
    ElMessage.success(res.msg);
    addObjectProjectObject.value =[{
      region:'',
      provincialCity:'',
      hospitalName:'',
      visitTime:'',
      projectStage:'',
      visitor:'',
      hospitalStaffContact:'',
      Phone:'',
      clinicTime:'',
      dealerCompanyName:'',
      visitObjective:'',
      communicationContent:'',
      visitResult:'',
      mainIssues:'',
      nextStepPlan:'',
      expectedNextVisitTime:''
    }]
    addObjectProjectFlag.value = false;
    await query();
  } else {
    ElMessage.error(res.msg);
  }

}
const addRegional_addHospital = ()=>{
  addRegionalHospitalObject.value. leadHospitals.push({
    name:'',
    address:'',
  })
}
const addRegional_addThridHospital = ()=>{
  addRegionalHospitalObject.value.thirdHospital.push({
    name:'',
    address:'',
  })
}
const addObject_Project_one =()=>{
  let s  = {
    region:'',
    provincialCity:'',
    hospitalName:'',
    visitTime:'',
    projectStage:'',
    visitor:'',
    hospitalStaffContact:'',
    Phone:'',
    clinicTime:'',
    dealerCompanyName:'',
    visitObjective:'',
    communicationContent:'',
    visitResult:'',
    mainIssues:'',
    nextStepPlan:'',
    expectedNextVisitTime:''
  }
  addObjectProjectObject.value.push(s);

}
function resetAddOutSidePlanObject() {
  addOutSidePlanObject.value = {
    post: '',
    fromMan: '',
    fromManName: '',
    sysDeptName: '',
    sysDeptid: '',
    postName: '',
    datePlan: [{
      date: '',
      times: [
        {
          period: '',
          unit: '',
          offices: '',
          character: '',
          objective: '',
          transportation: ''
        }
      ]
    }]
  }
}
const addDealerBaseInfoOne =()=>{
  let b={
    companyNature:'',
    marketArea:'',
    mainDepartment:'',
    mainProducts:'',
    contactPersonName:'',
    post:'',
    phone:'',
    estimate:{
      region : '',
      director : '',
      phone : '',
      workManNUmber : '',
      saleTeam : '',
      saleManNumber : '',
      customerNumber : '',
      sanjia : '',
      erjia : '',
      outher : '',
      products : '',
      comprehensiv : '',
      tableData:[{
        num: 1,
        project: '价值取向（20分）',
        'infoandfen': [
          {content: '1、认同、支持公司经营理念和名牌战略'},
          {content: '2、遵循公司的价格和市场管理策略'},
          {content: '3、是否愿意与公司保持稳定的经销关系'},
          {content: '4、不经营与公司产品有明显竞争性质的产品'},
          {content: '5、在所有经营产品中，把公司产品作为主营产品'},
          {content: '6、资信程度高，能遵循公司现款现货的原则'},
          {content: '7、同公司保持良好的沟通，与公司保持同步发展'},
          {content: '8、能主动及时处理或协同公司处理客户的异议'},
          {content: '9、整个团队诚实可信，在当地有着良好的声誉'},
        ],
        fen: [
          {content: 3},
          {content: 3},
          {content: 2},
          {content: 2},
          {content: 2},
          {content: 2},
          {content: 2},
          {content: 2},
          {content: 1},
        ],
        da: ['', '', '', '', '', '', '', '', '',],
        sum: '',
      }],
      tableData2:[{
        num: 2,
        project: '经营能力（30分）',
        'infoandfen': [
          { content: '10、具有良好的经销网络' },
          { content: '11、有专职的销售队伍' },
          { content: '12、有充足的可供市场运作的资金' },
          { content: '13、具有一个高素质且团结奋进的良好团队' },
          { content: '14、同政府机关单位保持有良好的关系' },
          { content: '15、有电话、传真和电脑等通讯等办公设施，有良好的办公场所' },
          { content: '16、有丰富的市场营销经验和超前的经营意识' },
          { content: '17、权力集中、经营机制灵活，可以根据市场情况迅速做出反应' },
        ],
        fen: [
          { content: 6},
          { content: 4},
          { content: 5},
          { content: 2},
          { content: 2},
          { content: 2},
          { content: 2},
          { content: 2},
        ],
        da: ['', '', '', '', '', '', '', '' ,],
        sum: '',
      },],
      tableData3:[{
        num: 3,
        project: '积极性（15分）',
        'infoandfen': [
          { content: '18、能够根据市场的发展主动组织各项会销等市场活动' },
          { content: '19、积极配合公司的各项政策及要求，提供充足的人力和物力支持' },
          { content: '20、积极向公司提供各种合理化建议' },
          { content: '21、积极主动推广公司的各种产品' },
          { content: '22、积极配合公司的市场调研工作' },
        ],
        fen: [
          { content: 3},
          { content: 3},
          { content: 2},
          { content: 2},
          { content: 2},
        ],
        da: ['', '', '', '', '', ],
        sum: '',
      },],
      tableData4:[{
        num: 4,
        project: '销售业绩（15分）',
        'infoandfen': [
          { content: '近一年营业收入500万以下' },
          { content: '近一年营业收入500万-1000万' },
          { content: '近一年营业收入1000万-2000万' },
          { content: '近一年营业收入2000万以上' },
        ],
        fen: [
          { content: 3},
          { content: 5},
          { content: 10},
          { content: 15},
        ],
        da: ['', '', '', '', ],
        sum: '',
      }]
    },
    allflag:false
  }
  addDealerBaseInfoObject.value.push(b);
}

const addNewProjectScheduleObject = async() =>{
  addProjectScheduleObject.value.push({date:''})
}
const handleSuccess =(res)=>{
  if (res.code == 200){
    let b  ={
      fileName : res.data.originalFileName,
      url:  res.data.url
    }
    addHospatilObject.value.fileList.push(b)
  }else {
    ElMessage.error(res.msg)
  }

}

const handleSucces2 =(res)=>{
  if (res.code == 200){
    let b  ={
      fileName : res.data.originalFileName,
      url:  res.data.url
    }
    addmedicalInformationObject.value.fileList.push(b)
  }else {
    ElMessage.error(res.msg)
  }
}
const cleanDealerEvaluation =  () => {
  addDealerEvaluationObject.value.region = ''
  addDealerEvaluationObject.value.director = ''
  addDealerEvaluationObject.value.phone = ''
  addDealerEvaluationObject.value.workManNUmber = ''
  addDealerEvaluationObject.value.saleTeam = ''
  addDealerEvaluationObject.value.saleManNumber = ''
  addDealerEvaluationObject.value.customerNumber = ''
  addDealerEvaluationObject.value.sanjia = ''
  addDealerEvaluationObject.value.erjia = ''
  addDealerEvaluationObject.value.outher = ''
  addDealerEvaluationObject.value.products = ''
  addDealerEvaluationObject.value.comprehensiv = ''
  addDealerEvaluationObject.value.tableData = [{
    num: 1,
    project: '价值取向（20分）',
    'infoandfen': [
      {content: '1、认同、支持公司经营理念和名牌战略'},
      {content: '2、遵循公司的价格和市场管理策略'},
      {content: '3、是否愿意与公司保持稳定的经销关系'},
      {content: '4、不经营与公司产品有明显竞争性质的产品'},
      {content: '5、在所有经营产品中，把公司产品作为主营产品'},
      {content: '6、资信程度高，能遵循公司现款现货的原则'},
      {content: '7、同公司保持良好的沟通，与公司保持同步发展'},
      {content: '8、能主动及时处理或协同公司处理客户的异议'},
      {content: '9、整个团队诚实可信，在当地有着良好的声誉'},
    ],
    fen: [
      {content: 3},
      {content: 3},
      {content: 2},
      {content: 2},
      {content: 2},
      {content: 2},
      {content: 2},
      {content: 2},
      {content: 1},
    ],
    da: ['', '', '', '', '', '', '', '', '',],
    sum: '',
  }]
  addDealerEvaluationObject.value.tableData2 =[{
    num: 2,
    project: '经营能力（30分）',
    'infoandfen': [
      { content: '10、具有良好的经销网络' },
      { content: '11、有专职的销售队伍' },
      { content: '12、有充足的可供市场运作的资金' },
      { content: '13、具有一个高素质且团结奋进的良好团队' },
      { content: '14、同政府机关单位保持有良好的关系' },
      { content: '15、有电话、传真和电脑等通讯等办公设施，有良好的办公场所' },
      { content: '16、有丰富的市场营销经验和超前的经营意识' },
      { content: '17、权力集中、经营机制灵活，可以根据市场情况迅速做出反应' },
    ],
    fen: [
      { content: 6},
      { content: 4},
      { content: 5},
      { content: 2},
      { content: 2},
      { content: 2},
      { content: 2},
      { content: 2},
    ],
    da: ['', '', '', '', '', '', '', '' ,],
    sum: '',
  },]
  addDealerEvaluationObject.value.tableData3 =[{
    num: 3,
    project: '积极性（15分）',
    'infoandfen': [
      { content: '18、能够根据市场的发展主动组织各项会销等市场活动' },
      { content: '19、积极配合公司的各项政策及要求，提供充足的人力和物力支持' },
      { content: '20、积极向公司提供各种合理化建议' },
      { content: '21、积极主动推广公司的各种产品' },
      { content: '22、积极配合公司的市场调研工作' },
    ],
    fen: [
      { content: 3},
      { content: 3},
      { content: 2},
      { content: 2},
      { content: 2},
    ],
    da: ['', '', '', '', '', ],
    sum: '',
  },]
  addDealerEvaluationObject.value.tableData4 =[{
    num: 4,
    project: '销售业绩（15分）',
    'infoandfen': [
      { content: '近一年营业收入500万以下' },
      { content: '近一年营业收入500万-1000万' },
      { content: '近一年营业收入1000万-2000万' },
      { content: '近一年营业收入2000万以上' },
    ],
    fen: [
      { content: 3},
      { content: 5},
      { content: 10},
      { content: 15},
    ],
    da: ['', '', '', '', ],
    sum: '',
  }]
}

let dealerBaseInfoIndex = ref<number>(0)
const addestimate = (index)=>{
  dealerBaseInfoIndex.value =index;
  addDealerEvaluationFlag.value =true;
  addDealerEvaluationObject.value.dealerName =addDealerBaseInfoObject.value[index].dealerName
  addDealerEvaluationObject.value.address =addDealerBaseInfoObject.value[index].address
  if (addDealerBaseInfoObject.value[index].allflag == false) {
      cleanDealerEvaluation()
  }else{
    console.log(addDealerBaseInfoObject.value[index])
    addDealerEvaluationObject.value.region = addDealerBaseInfoObject.value[index].estimate.region;
    addDealerEvaluationObject.value.director = addDealerBaseInfoObject.value[index].estimate.director;
    addDealerEvaluationObject.value.phone = addDealerBaseInfoObject.value[index].estimate.phone;
    addDealerEvaluationObject.value.workManNUmber = addDealerBaseInfoObject.value[index].estimate.workManNUmber;
    addDealerEvaluationObject.value.saleTeam = addDealerBaseInfoObject.value[index].estimate.saleTeam;
    addDealerEvaluationObject.value.saleManNumber = addDealerBaseInfoObject.value[index].estimate.saleManNumber;
    addDealerEvaluationObject.value.customerNumber = addDealerBaseInfoObject.value[index].estimate.customerNumber;
    addDealerEvaluationObject.value.sanjia = addDealerBaseInfoObject.value[index].estimate.sanjia;
    addDealerEvaluationObject.value.erjia = addDealerBaseInfoObject.value[index].estimate.erjia;
    addDealerEvaluationObject.value.outher = addDealerBaseInfoObject.value[index].estimate.outher;
    addDealerEvaluationObject.value.products = addDealerBaseInfoObject.value[index].estimate.products;
    addDealerEvaluationObject.value.comprehensiv = addDealerBaseInfoObject.value[index].estimate.comprehensiv;
    addDealerEvaluationObject.value.tableData = addDealerBaseInfoObject.value[index].estimate.tableData;
    addDealerEvaluationObject.value.tableData2 = addDealerBaseInfoObject.value[index].estimate.tableData2;
    addDealerEvaluationObject.value.tableData3 = addDealerBaseInfoObject.value[index].estimate.tableData3;
    addDealerEvaluationObject.value.tableData4 = addDealerBaseInfoObject.value[index].estimate.tableData4;
  }

}

/**
 * 添加经销商评价
 */
const adddealerEvaluationSubmit = async () => {
  addDealerBaseInfoObject.value[dealerBaseInfoIndex.value].estimate ={...addDealerEvaluationObject.value}
  addDealerBaseInfoObject.value[dealerBaseInfoIndex.value].allflag =true;
  addDealerEvaluationFlag.value =false;
  addDealerEvaluationFlag.value =false
  cleanDealerEvaluation
}

/**
 * 添加医学信息日志
 */
const addmedicalInformationLogSubmit = async () => {
  await uploadRef2.value!.submit()
  const jsonString = JSON.stringify(addmedicalInformationObject.value);
  const res = await submitLaunch({
    processDefinitionKey: 'medicalinformationlog',
    formKey: import.meta.env.VITE_MEDICAL_INFORMATION_LOG,
    formData: jsonString
  });
  if (res.code == 200) {
    ElMessage.success(res.msg);
    addoutSide.value = false;
    await query();
  } else {
    ElMessage.error(res.msg);
  }
}
/**
 * 添加渠道信息日志
 */
const addChannelLogSubmit = async () => {
  const jsonString = JSON.stringify(addChannelLogSubmit.value);
  const res = await submitLaunch({
    processDefinitionKey: 'channel_logs',
    formKey: import.meta.env.VITE_CHANNEL_LOGS,
    formData: jsonString
  });
  if (res.code == 200) {
    ElMessage.success(res.msg);
    addoutSide.value = false;
    await query();
  } else {
    ElMessage.error(res.msg);
  }

}
/**
 * 添加售前工程师信息日志
 */
const addPreSalesEngineerSubmit = async () => {
  const jsonString = JSON.stringify(addPreSalesEngineerObject.value);
  const res = await submitLaunch({
    processDefinitionKey: 'presalesengineerlog',
    formKey: import.meta.env.VITE_PRE_SALES_ENGINEER_LOG,
    formData: jsonString
  });
  if (res.code == 200) {
    ElMessage.success(res.msg);
    addoutSide.value = false;
    await query();
  } else {
    ElMessage.error(res.msg);
  }
}

</script>
<style scoped>
.target>>>.el-form-item__content {
  width: 162.5vh;
}
.dafe{
  margin-top: 2rem;
  display: inline-block;

}
.dafen>>>.el-input__inner {

}
.dafen>>>.el-input__wrapper{
  position: relative;
  top:0.5rem;
  overflow: hidden;
  box-sizing: border-box;
  height: -webkit-fit-content;
  height: -moz-fit-content;
  height: fit-content;
  width: 100%;
  max-width: 100%;
  background-color: var(--el-table-bg-color);
  font-size: 14px;
  color: var(--el-table-text-color);
  padding: 5px 0;
  min-width: 0;
  border: 0;
  border-bottom: 1px solid #EBEEF5;
  border-radius: 0px;
  box-shadow: none;
  box-sizing: border-box;
  text-overflow: ellipsis;
  vertical-align: middle;
  position: relative;
  text-align: left;
  z-index: 1;
}

.add_form>div {
  display: flex;
  justify-content: center;
  align-items: center
}


.add_table {
  display: flex;
  flex-direction:column;
  justify-content: center;
  align-items: center;
  margin-bottom: 1rem;
}
.add_table td:first-child {
  text-align: end;
}

.add_table td:last-child {
  text-align: start;
}


.add_table td{
  width: 15rem;
}

.el-input {
  width: 15rem;
  display: inline-block;
}
.long_input {
  width: 30rem;
  display: flex;;
}
.addDealerBaseInfoBox{
  margin: 1rem;
  padding: 1rem;
  border: 1px solid black;

}
</style>
